home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / runner1a / regplus.bas < prev    next >
BASIC Source File  |  1999-09-14  |  5KB  |  87 lines

  1. Attribute VB_Name = "RegPlus"
  2. Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hkey As Long) As Long
  3. Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hkey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
  4. Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hkey As Long, ByVal lpSubKey As String) As Long
  5. Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hkey As Long, ByVal lpValueName As String) As Long
  6. Declare Function RegEnumKey Lib "advapi32.dll" Alias "RegEnumKeyA" (ByVal hkey As Long, ByVal dwIndex As Long, ByVal lpName As String, ByVal cbName As Long) As Long
  7. Declare Function RegEnumValue Lib "advapi32.dll" Alias "RegEnumValueA" (ByVal hkey As Long, ByVal dwIndex As Long, ByVal lpValueName As String, lpcbValueName As Long, lpReserved As Long, lpType As Long, lpData As Byte, lpcbData As Long) As Long
  8. Declare Function RegFlushKey Lib "advapi32.dll" (ByVal hkey As Long) As Long
  9. Declare Function RegLoadKey Lib "advapi32.dll" Alias "RegLoadKeyA" (ByVal hkey As Long, ByVal lpSubKey As String, ByVal lpFile As String) As Long
  10. Declare Function RegNotifyChangeKeyValue Lib "advapi32.dll" (ByVal hkey As Long, ByVal bWatchSubtree As Long, ByVal dwNotifyFilter As Long, ByVal hEvent As Long, ByVal fAsynchronus As Long) As Long
  11. Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hkey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
  12. Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hkey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
  13. Declare Function RegQueryValue Lib "advapi32.dll" Alias "RegQueryValueA" (ByVal hkey As Long, ByVal lpSubKey As String, ByVal lpValue As String, lpcbValue As Long) As Long
  14. Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hkey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
  15. Declare Function RegReplaceKey Lib "advapi32.dll" Alias "RegReplaceKeyA" (ByVal hkey As Long, ByVal lpSubKey As String, ByVal lpNewFile As String, ByVal lpOldFile As String) As Long
  16. Declare Function RegRestoreKey Lib "advapi32.dll" Alias "RegRestoreKeyA" (ByVal hkey As Long, ByVal lpFile As String, ByVal dwFlags As Long) As Long
  17. Declare Function RegSetValue Lib "advapi32.dll" Alias "RegSetValueA" (ByVal hkey As Long, ByVal lpSubKey As String, ByVal dwType As Long, ByVal lpData As String, ByVal cbData As Long) As Long
  18. Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hkey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
  19. Declare Function RegUnLoadKey Lib "advapi32.dll" Alias "RegUnLoadKeyA" (ByVal hkey As Long, ByVal lpSubKey As String) As Long
  20. Public Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
  21. Global Cretnew As Boolean
  22. Function RegQueryStringValue(ByVal hkey As Long, ByVal strValueName As String)
  23.     Dim lResult As Long
  24.     Dim lValueType As Long
  25.     Dim strBuf As String
  26.     Dim lDataBufSize As Long
  27.     Dim ERROR_SUCCESS
  28.     On Error GoTo 0
  29.     lResult = RegQueryValueEx(hkey, strValueName, 0&, lValueType, ByVal 0&, lDataBufSize)
  30.     If lResult = ERROR_SUCCESS Then
  31.         If lValueType = REG_SZ Then
  32.             strBuf = String(lDataBufSize, " ")
  33.             lResult = RegQueryValueEx(hkey, strValueName, 0&, 0&, ByVal strBuf, lDataBufSize)
  34.             If lResult = ERROR_SUCCESS Then
  35.                 RegQueryStringValue = StripTerminator(strBuf)
  36.             End If
  37.         End If
  38.     End If
  39. End Function
  40. Public Function getstring(hkey As Long, strpath As String, strvalue As String)
  41. Dim keyhand&
  42. Dim datatype&
  43. r = RegOpenKey(hkey, strpath, keyhand&)
  44. getstring = RegQueryStringValue(keyhand&, strvalue)
  45. r = RegCloseKey(keyhand&)
  46. End Function
  47. Function StripTerminator(ByVal strString As String) As String
  48.     Dim intZeroPos As Integer
  49.  
  50.     intZeroPos = InStr(strString, Chr$(0))
  51.     If intZeroPos > 0 Then
  52.         StripTerminator = Left$(strString, intZeroPos - 1)
  53.     Else
  54.         StripTerminator = strString
  55.     End If
  56. End Function
  57.  
  58. Public Sub savestring(hkey As Long, strpath As String, strvalue As String, strdata As String)
  59. Dim keyhand&
  60. r = RegCreateKey(hkey, strpath, keyhand&)
  61. r = RegSetValueEx(keyhand&, strvalue, 0, REG_SZ, ByVal strdata, Len(strdata))
  62. r = RegCloseKey(keyhand&)
  63. End Sub
  64. Sub Wait(WaitSeconds As Single)
  65.  
  66. Dim StartTime As Single
  67.  
  68. StartTime = Timer
  69.  
  70. Do While Timer < StartTime + WaitSeconds
  71. DoEvents
  72. Loop
  73. End Sub
  74. Public Function Short_Name(Long_Path As String) As String
  75.  
  76.        '     'Returns short path of the passed long path
  77.        Dim Short_Path As String
  78.        Dim Answer As Long
  79.        Short_Path = Space(250)
  80.        Answer = GetShortPathName(Long_Path, Short_Path, Len(Short_Path))
  81.  
  82.               If Answer Then
  83.                      Short_Name = Left$(Short_Path, Answer)
  84.               End If
  85.  
  86. End Function
  87.